import java.util.StringTokenizer;
import java.util.Vector;

class P850_39643 {

	public static void main(String[] args) {

		int cases = Integer.parseInt(readLn());
		readLn();
		for (int k = 0; k < cases; k++) {
			process();
			if (k + 1 != cases)
				System.out.println();

		}

	}

	static String[] key = { "the", "quick", "brown", "fox", "jumps", "over",
			"the", "lazy", "dog" };

	static int[] sizes = { 3, 5, 5, 3, 5, 4, 3, 4, 3 };

	
	private static char[] getTable(Vector candidates, int size) {
		for (int k = 0; k < size; k++) {
			StringTokenizer st = new StringTokenizer((String) candidates
					.elementAt(k));
			char[] tableCrypted = new char[26];
			char[] tableDecrypted = new char[26];
			boolean[] tableBooleanCrypted = new boolean[26];
			boolean[] tableBooleanDecrypted = new boolean[26];

			boolean isThisCandidate = true;

			for (int j = 0; j < 9 && isThisCandidate; j++) {
				String word = st.nextToken();

				for (int i = 0; i < word.length() && isThisCandidate; i++) {
					if (!tableBooleanDecrypted[key[j].charAt(i) - 'a'] && !tableBooleanCrypted[word.charAt(i)-'a']) {
						tableDecrypted[key[j].charAt(i) - 'a'] = word.charAt(i);
						tableCrypted[word.charAt(i) - 'a'] = key[j].charAt(i);
						tableBooleanDecrypted[key[j].charAt(i) - 'a'] = true;
						tableBooleanCrypted[word.charAt(i) - 'a'] = true;
					} else {
						if (tableDecrypted[key[j].charAt(i) - 'a'] != word.charAt(i) || tableCrypted[word.charAt(i) - 'a'] != key[j].charAt(i)) {
							isThisCandidate = false;
						} 
					}
				}

			}
			if (isThisCandidate)
				return tableDecrypted;
		}

		return null;
	}
	
	private static void process() {

		Vector phrases = new Vector();

		Vector candidates = new Vector();

		String line = readLn();

		while (line != null && !"".equals(line)) {
			StringTokenizer st = new StringTokenizer(line);
			if (st.countTokens() == 9) {
				boolean isCandidate = true;

				for (int k = 0; k < 9 && isCandidate; k++) {
					if (st.nextToken().length() != sizes[k])
						isCandidate = false;
				}

				if (isCandidate)
					candidates.addElement(line);
			}

			phrases.addElement(line);

			line = readLn();
		}

		if (candidates.size() == 0) {
			System.out.println("No solution.");
			return;
		}

		char[] table = getTable(candidates, candidates.size());

		if (table == null) {
			System.out.println("No solution.");
			return;
		}

//		System.out.print(">>");
//		for (int k = 0; k < 26; k++) {
//			System.out.print(table[k] + " ");
//		}
//		System.out.println();
		
		decrypt(phrases, table);

	}

	private static void decrypt(Vector phrases, char[] table) {
		for (int k = 0; k < phrases.size(); k++) {

			System.out.println(decrypt((String) phrases.elementAt(k), table));

		}

	}

	private static String decrypt(String string, char[] table) {

		StringBuffer sb = new StringBuffer();

		for (int k = 0; k < string.length(); k++) {
			char c = string.charAt(k);

			if (c == ' ') {
				sb.append(' ');
			}
			else {
				for (int i = 0; i < table.length; i++) {
					if (c == table[i])
						sb.append((char) ('a' + i));
				}
			}

		}

		return sb.toString();
	}

	

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}
